<div class="SipeiMain_r fr">
    <h2 class="clearfix fonts_18 height45 fontc_444"><?php echo $this->title; ?></h2>
    <?php
    $type_array = array('' => '类别', '1' => '理科', '2' => '文科', '3'=>'艺体');
    ?>
    <div class="clearfix back_bgf border_3 border_c pt20 pr30 pb20 height32 fontc_666">
        <form action="<?php echo $this->createUrl('index'); ?>" method="get" class="clearfix pb10" id='searchForm'>
            <table>
                <tbody>
                    <tr>
                        <td align="right" width="88" class="pt10 pr3 pb10">科别代码：</td>
                        <td width="120" class="pt10 pb10">
                            <input type="text" name="disciplin_code" value="<?php echo (!empty($search['disciplin_code'])) ? $search['disciplin_code'] : ''; ?>" class="pt6 pr5 pb6 pl5 border_3 border_c fontc_666 w100" />
                        </td>
                        <td align="right" width="75" class="pt10 pr3 pb10">上报简称：</td>
                        <td width="120" class="pt10 pb10">
                            <input type="text" name="disciplin_nick" value="<?php echo (!empty($search['disciplin_nick'])) ? $search['disciplin_nick'] : '';  ?>" class="pt6 pr5 pb6 pl5 border_3 border_c fontc_666 w100" />
                        </td>
                        <td align="right" width="75" class="pt10 pr3 pb10">科别名称：</td>
                        <td width="120" class="pt10 pb10">                            
                            <input type="text" name="disciplin_name" value="<?php echo (!empty($search['disciplin_name'])) ? $search['disciplin_name'] : '';  ?>" class="pt6 pr5 pb6 pl5 border_3 border_c fontc_666 w100" />
                        </td>
                        <td width="160" class="pt10 pb10 text_right">
                            <input type="submit" value="查询" class="b_a_n border_3 back_bgfb w80 height32 fontc_FFF fonts_12 cursor" />
                        </td>
                    </tr>
                    <tr>
                        <td  align="right"class="pt10 pr3">包含科目：</td>
                        <td class="pt10">
                            <span class="fl standard_select pt5 pr7 pb5 pl3 border_c border_3"> 
                                <span class="fl select_shelter  select_shelter2"> 
                                    <select class="fl fontc_666" name="edu_type">
                                        <option value="0">请选择</option>
                                        <?php if (!empty($subject)): ?>
                                            <?php foreach ($subject as $sv): ?>
                                                <option value="<?php echo $sv['subject_id'] ?>"<?php echo (!empty($search['edu_type']) && $search['edu_type'] == $sv['subject_id']) ? 'selected' :'';?>>
                                                <?php echo $sv['subject_name'] ?>
                                                </option>
                                            <?php endforeach; ?>
                                        <?php endif; ?>
                                    </select> 
                                </span> 
                            </span>
                        </td>
                        <td align="right" class="pt10 pr3">所属类别：</td>
                        <td class="pt10">                            
                            <span class="fl standard_select pt5 pr7 pb5 pl3 border_c border_3"> 
                                <span class="fl select_shelter  select_shelter2"> 
                                    <select class="fl fontc_666" name="disciplin_type">
                                    	<option value="0">请选择</option>
                                        <option value="1" <?php echo (!empty($search['disciplin_type']) && $search['disciplin_type'] ==1) ? 'selected' :''; ?>>理科</option>
                                        <option value="2"<?php echo (!empty($search['disciplin_type']) && $search['disciplin_type'] ==2) ? 'selected' :'' ; ?>>文科</option>
                                    </select> 
                                </span> 
                            </span>
                        </td>
                        
                    </tr>
                </tbody>
            </table>
        </form>
    </div>
    <div class="clearfix back_bgf border_c mt15 pt20 pb20">
        <div class="clearfix pb20 pl30">
            <input type="button" onclick="add()" value="新增" style="margin-right:30px;" class="b_a_n border_3 back_bgfb w80 height32 fontc_FFF fonts_12 cursor fr" />
            <input type="button" value="删除" onclick="delete_all()"  class="fl b_a_n border_3 back_bgfb w80 height32 fontc_FFF fonts_12 cursor" />
        </div>
        <form>
            <table class="height40">
                <thead class="back_bgf5 fontc_666">
                    <tr>
                    	<th width="40" align="right" class="m_hr_t m_hr_b pr10"><input type="checkbox" class="checkboxs"></th>
                        <th width="95" align="center" class="m_hr_t m_hr_b pr5">代码</th>
                        <th width="90" align="center" class="m_hr_t m_hr_b pr5">上报简称</th>
                        <th width="120" align="center" class="m_hr_t m_hr_b pr5">科别名称</th>
                        <th width="80" align="center" class="m_hr_t m_hr_b pr5">类别</th>
                        <th width="90" align="center" class="m_hr_t m_hr_b pr5">包含科目</th>
                        <th width="65" align="center" class="m_hr_t m_hr_b">是否生效</th>
                        <th width="140" align="center" class="m_hr_t m_hr_b pr5">备注</th>
                        <th width="90" align="center" class="m_hr_t m_hr_b">操作</th>
                    </tr>
                </thead>
                <tbody class="fontc_444">
                    <?php if (!empty($data)): ?>
                        <?php foreach ($data as $value): ?>
                            <tr>
                            	<td align="right" class="m_hr_b pr10"><input type="checkbox" name="deleteAll[]" value="<?php echo $value['disciplin_id'];?>" class="checkbox"></td>
                                <td align="center" class="m_hr_b height20 pt5 pr5 pb5"><?php echo $value['disciplin_code']; ?></td>
                                <td align="center" class="m_hr_b height20 pt5 pr5 pb5"><?php echo $value['disciplin_nick']; ?></td>
                                <td align="center" class="m_hr_b height20 pt5 pr5 pb5"><?php echo $value['disciplin_name']; ?></td>
                                <td align="center" class="m_hr_b height20 pt5 pr5 pb5"><?php echo $type_array[$value['disciplin_type']]; ?></td>
                                <td align="center" class="m_hr_b height20 pt5 pr5 pb5">
                                    <?php if (!empty($value['subject_info'])): ?>
                                        <?php foreach ($value['subject_info'] as $sv): ?>
                                            <?php echo $sv['subject_name']; ?>
                                        <?php endforeach; ?>
                                    <?php endif; ?>
                                </td>
                                <?php if ($value['disabled'] == 1): ?>
                                    <td align="center" class="m_hr_b">
                                        <input type="checkbox"  disabled='' checked="checked" />
                                    </td>
                                <?php else: ?>
                                    <td align="center" class="m_hr_b">
                                        <input type="checkbox" disabled=''/>
                                    </td>
                                <?php endif; ?>
                                <td align="center" class="m_hr_b height20 pt5 pr5 pb5" title="<?php echo $value['description'];?>"><?php echo (!empty($value['description'])) ? Func::get_word($value['description'], 15) : $value['description']; ?></td>
                                <td align="center" class="m_hr_b">
                                    <img src="/themes/default/images/Sipei/edit.png" title="编辑" class="mr10 cursor" onclick="update(<?php echo $value['disciplin_id'] ?>)" />
                                    <img src="/themes/default/images/Sipei/delate.png" title="删除" class="cursor" onclick="set_ok(<?php echo $value['disciplin_id']; ?>)" />
                                </td>
                            </tr>
                        <?php endforeach; ?>
                    <?php else: ?>
                        <tr>
                            <td colspan="9"><h1 align="center">暂无数据</h1></td>
                        </tr>
                    <?php endif; ?>

                </tbody>
            </table>
        </form>
        <?php $this->renderPartial('//partial/partial_pager', array('pages' => $pages, "url" => $pageUrl)); ?>

    </div>
</div>

<script>
                function set_ok(disciplin_id) {
            
                    $.dialog.confirm('确定删除吗', function() {
                       $.get('/disciplin/default/delete_all', {disciplin_id: disciplin_id}, function(data) {
                  			location.reload();
                  		   
                  		});
                    });
                }

                function delete_all(){
                	var aa='';

                	$("input[name='deleteAll[]']:checkbox:checked").each(function(){
						aa+=$(this).val()+',';
					});

					if(aa == ''){
						$.dialog.alert("请选择要删除条目");
						return false;
					}

					$.dialog.confirm('确定删除所选数据吗', function() {
                		aa+=0;
                		$.get('/disciplin/default/delete_all', {disciplin_id: aa}, function(data) {
                			location.reload();
                		   
                		});
                	});
                }

                
                function add() {
                    api = $.dialog({
                        id: 'testID2',
                        lock: true,
                        padding: 0,
                        fixed: true,
                        title: "新增",
                        width: 500,
                        height: 600,
                        max: false,
                        min: false
                    });
                    $.get('/disciplin/default/add', function(html) {
                        api.content(html);
                    });
                }

                function update(disciplin_id) {

                    api = $.dialog({
                        id: 'testID2',
                        lock: true,
                        padding: 0,
                        fixed: true,
                        title: "编辑",
                        width: 500,
                        height: 600,
                        max: false,
                        min: false
                    });
                    $.get('/disciplin/default/update', {disciplin_id: disciplin_id,time:new Date()}, function(html) {
                        api.content(html);
                    });
                }
	$(function() {
                    $(".checkboxs").click(function() {
                        var checkedS = $(this).attr("checked");
                        if (checkedS) {
                            $(".checkbox").attr("checked", true)
                        } else {
                            $(".checkbox").removeAttr("checked")
                        }
                    })

                })
</script>